#include "thread.h"


#include <QTime>
#include <QDebug>
int TimeThread::num = 0;
QMutex TimeThread::mutex;
TimeThread::TimeThread(QWidget* parent):QThread(parent)
{
}
void TimeThread::run()
{
// while(1)
// {
// QString time = QTime::currentTime().toString("hh:mm:ss");
// qDebug() << time;
// emit sendTime(time); //发送信号
// sleep(1);
// }

    for(int i=0;i<1000;i++)
    {   {
        QMutexLocker lock(&this->mutex);//自动j解锁
        //this->mutex.lock(); //加锁
         num++;
        //this->mutex.unlock(); //解锁
       // QThread::sleep(1); //线程睡眠两秒

        }

     }
       qDebug() << "Current Thread: " << this << ", Value: " << this->num;
}
